﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ZeroTouchUI
{
    /// <summary>
    /// Interaction logic for Loading.xaml
    /// </summary>
    public partial class Loading : Window
    {
        private delegate void StartProcess();
        public Loading()
        {
            InitializeComponent();
            Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
            foreach (Process p in processes)
            {
                //IntPtr pFoundWindow = p.MainWindowHandle;
                if (p.Id != Process.GetCurrentProcess().Id)
                {
                    MessageBox.Show("This application is already running. It may be minimized in your taskbar. This session will now close.",
                                    "Application already open", MessageBoxButton.OK);
                    System.Windows.Application.Current.Shutdown();
                }
            }
        }

        private void Window_Loaded(object sender, EventArgs e)
        {
            MainWindow mw = new MainWindow();
            mw.Show();
            this.Close();
        }
    }
}
